#include "GrowRasterDemo.h"

/*
 * -G -> GROW METHODS
 * -R -> RASTER SCAN
 * -A -> AUTO DISPLAY
 *  */

int main(int argc, char **argv)
{

  ImageProcessingState procState;
  
  /* show initial image */
  printGrowMatrix();

  /* init correct processing module and assign state */
  if(3 <= argc)
  {

    if(strcmp(argv[2], "-G") == 0)
    {

      initGrow(argv[1]);
      procState = GROW_STATE;

    }
    else if(strcmp(argv[2], "-R") == 0)
    {

      initRasterScan(argv[1]);
      procState = RASTER_SCAN_STATE;

    }
    else
    {
      printf("ERROR: No Image Processor Defined\n\n");
      return -1;
    }
  }
  else
  {
    printf("ERROR: No Image Processor Defined\n\n");
  }

  /* init the processing sequence */
  if(4 == argc)
  {
    if(strcmp(argv[3], "-A") == 0)
    {
      if(GROW_STATE == procState)
      {
        startAutoGrow(GROW_DISPLAY_GROW_ANIMATION);
      }
      else if(RASTER_SCAN_STATE == procState)
      {
        startAutoRasterScan(RASTERSCAN_DISPLAY_RASTERSCAN_ANIMATION);
      }
    }
  }
  else
  {
    if(GROW_STATE == procState)
    {
      startAutoGrow(GROW_DISPLAY_END);
    }
    else if(RASTER_SCAN_STATE == procState)
    {
      startAutoRasterScan(RASTERSCAN_DISPLAY_END);
    }
  }
  


  /* set finishing displays */
  if(GROW_STATE == procState)
  {
    printGrowMatrix();
    deallocGrow();
  }
  else if(RASTER_SCAN_STATE)
  {
    printRasterScanMatrix();
    deallocRasterScan();
  }

  return 0;
}
